package com.barbeque.mall.controller.wx;

import com.barbeque.mall.bean.BasePageInfo;
import com.barbeque.mall.bean.BaseRespVo;
import com.barbeque.mall.bean.param.CommonData;
import com.barbeque.mall.bean.user.MarketCollect;
import com.barbeque.mall.bean.user.MarketUser;
import com.barbeque.mall.bean.wx.collect.ListOfCollectVo;
import com.barbeque.mall.service.wx.CollectService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ycc
 * @date 2022/07/20 13:54:40
 */
@RestController
@RequestMapping("wx/collect")
public class WxCollectController {

    @Autowired
    CollectService collectService;

    //http://localhost:8083/wx/collect/list?type=0&page=1&limit=10
    @GetMapping("list")
    public BaseRespVo list(BasePageInfo pageInfo,Integer type){
        CommonData<ListOfCollectVo> list = collectService.list(pageInfo,type);
        return BaseRespVo.ok(list);
    }

    //http://localhost:8083/wx/collect/addordelete
    @PostMapping("addordelete")
    public BaseRespVo addordelete(@RequestBody MarketCollect collect){
        int affectedRows = collectService.addordelete(collect);
        if (affectedRows==0) {
            return BaseRespVo.invalidData();
        }
        return BaseRespVo.ok(null);
    }
}
